Skip to content

feat: Wire LDAIMetrics tool_calls and duration_ms into tracker#152

Closed
jsonbailey wants to merge 4 commits intojb/aic-2388/managed-graph-resultfrom
jb/aic-2388/enrich-metrics
Closed

feat: Wire LDAIMetrics tool_calls and duration_ms into tracker#152
jsonbailey wants to merge 4 commits intojb/aic-2388/managed-graph-resultfrom
jb/aic-2388/enrich-metrics

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

Summary

Pins down the contract for the new tool_calls and duration_ms fields on LDAIMetrics. The integration was introduced incrementally as the OpenAI and LangChain runners migrated; this PR adds test coverage that will guard the contract going forward.

  • LDAIMetrics.to_dict() exposes toolCalls and durationMs
  • track_metrics_of / track_metrics_of_async use a runner-supplied duration_ms directly when present, otherwise measure elapsed wall-clock time
  • track_metrics_of calls track_tool_calls() when metrics.tool_calls is present, emitting one $ld:ai:tool_call event per key and recording the list on LDAIMetricSummary

Stack

PR 7 → PR 8 → PR 8-openai → PR 8-langchain → PR 9 → PR 10 (this) → PR 11 → PR 11-openai → PR 11-langchain → PR 12

Test plan

  • make test — 267 tests pass
  • make lint — mypy clean

🤖 Generated with Claude Code

@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 98e3ccc to cbe2eda Compare April 28, 2026 23:24
@jsonbailey jsonbailey changed the title feat(ldai): Wire LDAIMetrics tool_calls and duration_ms into tracker feat: Wire LDAIMetrics tool_calls and duration_ms into tracker Apr 28, 2026
@jsonbailey jsonbailey force-pushed the jb/aic-2388/managed-graph-result branch from d847d83 to 9c9e802 Compare April 29, 2026 13:15
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from cbe2eda to 4f12618 Compare April 29, 2026 13:15
@jsonbailey jsonbailey force-pushed the jb/aic-2388/managed-graph-result branch from 9c9e802 to 5fb879e Compare April 29, 2026 13:19
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 4f12618 to 351f249 Compare April 29, 2026 13:19
@jsonbailey jsonbailey force-pushed the jb/aic-2388/managed-graph-result branch from 5fb879e to 4319954 Compare April 29, 2026 13:22
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 351f249 to ef03235 Compare April 29, 2026 13:22
@jsonbailey jsonbailey force-pushed the jb/aic-2388/managed-graph-result branch from 4319954 to ba64a62 Compare April 29, 2026 13:50
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from ef03235 to e5ecc6a Compare April 29, 2026 13:52
@jsonbailey jsonbailey force-pushed the jb/aic-2388/managed-graph-result branch from ba64a62 to 49e95a3 Compare April 29, 2026 13:56
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from e5ecc6a to 1636446 Compare April 29, 2026 13:57
@jsonbailey jsonbailey force-pushed the jb/aic-2388/managed-graph-result branch from 49e95a3 to 80d4e11 Compare April 29, 2026 14:38
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 1636446 to 0fae2df Compare April 29, 2026 14:38
jsonbailey and others added 3 commits April 29, 2026 11:31
…nnerResult

- OpenAIModelRunner.run() implements the unified Runner protocol; returns RunnerResult
  with content, metrics (LDAIMetrics), raw, and parsed fields. Structured output is
  supported via the output_type parameter.
- OpenAIAgentRunner.run() updated to return RunnerResult; populates tool_calls in
  LDAIMetrics from observed openai-agents ToolCallItems.
- Legacy invoke_model() and invoke_structured_model() retained as deprecated adapters
  that delegate to run() and wrap results into ModelResponse / StructuredResponse for
  backward compatibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… RunnerResult

- LangChainModelRunner.run() implements the unified Runner protocol; returns RunnerResult
  with content, metrics (LDAIMetrics), raw, and parsed fields. Structured output is
  supported via the output_type parameter.
- LangChainAgentRunner.run() updated to return RunnerResult; populates tool_calls in
  LDAIMetrics from observed tool_calls in message responses.
- Legacy invoke_model() and invoke_structured_model() retained as deprecated adapters
  that delegate to run() and wrap results into ModelResponse / StructuredResponse for
  backward compatibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rResult types

- Add GraphMetrics dataclass (runner-layer return type for graph runs)
- Add GraphMetricSummary dataclass (managed-layer metrics, analogous to
  LDAIMetricSummary for single-model invocations)
- Add ManagedGraphResult dataclass (managed-layer return type from ManagedAgentGraph)
- Add AgentGraphRunnerResult dataclass (future runner return type, no evaluations field)
- ManagedAgentGraph.run() now returns ManagedGraphResult with GraphMetricSummary
  built from the runner's AgentGraphResult metrics
- Export all new types from ldai package

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-2388/managed-graph-result branch from 80d4e11 to 05e1f4c Compare April 29, 2026 16:33
@jsonbailey jsonbailey force-pushed the jb/aic-2388/enrich-metrics branch from 0fae2df to a468a7f Compare April 29, 2026 16:33
@jsonbailey jsonbailey force-pushed the jb/aic-2388/managed-graph-result branch from 05e1f4c to 0a1ee15 Compare April 30, 2026 14:02
@jsonbailey
Copy link
Copy Markdown
Contributor Author

Closing in favour of the cherry-pick in #148 — the tracker test coverage was moved into the jb/aic-2388/managed-result branch so it lands alongside the implementation rather than as a standalone follow-on PR.

@jsonbailey jsonbailey closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant